package com.itheima.controller;

import com.itheima.pojo.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;
import java.util.Map;

@Controller
public class ParamController {
    @RequestMapping("/req1")
    @ResponseBody
    public String param1(String str){
        System.out.println(str);
        return "{'info':'ok'}";
    }
    @RequestMapping("/req2")
    @ResponseBody
    public String param2(String username,String password){
        System.out.println(username);
        System.out.println(password);
        return "{'info':'ok'}";
    }
    @RequestMapping("/req3")
    @ResponseBody
    public String param3(Person person){
        System.out.println(person);
        return "{'info':'ok'}";
    }
    @RequestMapping("/req4")
    @ResponseBody
    public String param4(@RequestParam Map map){
        System.out.println(map);
        return "{'info':'ok'}";
    }

    //注解别名
    @RequestMapping("/req5")
    @ResponseBody
    public String param5(
            @RequestParam(value = "name1")String name,
            @RequestParam("age1")int age){
        System.out.println(name+"---->"+age);
        return "{'info':'ok'}";
    }

    @RequestMapping("/req6")
    @ResponseBody
    public String param6(@RequestParam String[] arr){
        System.out.println(Arrays.toString(arr));
        return "{'info':'ok'}";
    }
}
